package com.cat.dynamicPlanning02;

import java.util.Arrays;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/count-vowels-permutation/description/?envType=problem-list-v2&envId=Yvc80cti
 * @create 2025/10/1 21:52
 * @since JDK17
 */

public class Solution15 {
    public int countVowelPermutation(int n) {
        int N = ((int) (1e9 + 7));
        long ans = 0;
        long[][] dp = new long[n][5];
        Arrays.fill(dp[0], 1);
        for (int i = 1; i < n; i++) {
            dp[i][0] = (dp[i - 1][1] + dp[i - 1][4] + dp[i - 1][2]) % N;
            dp[i][1] = (dp[i - 1][0] + dp[i - 1][2]) % N;
            dp[i][2] = (dp[i - 1][1] + dp[i - 1][3]) % N;
            dp[i][3] = dp[i - 1][2];
            dp[i][4] = (dp[i - 1][2] + dp[i - 1][3]) % N;
        }
        for (int i = 0; i < 5; i++) {
            ans = (ans + dp[n - 1][i]) % N;
        }
        return ((int) ans);
    }
}
